Menu

Wiki usage

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.
Edit Sidebar
Main > MOHAAScriptLanguageAppendixA

Main.MOHAAScriptLanguageAppendixA History

Hide minor edits - Show changes to output

July 09, 2005, at 11:45 AM by 80.126.16.111
Changed lines 176-179 from:
||Example:||@@sighttrace ( 20 30 3045 ) ( 0 0 0 ) 1@@||
||Description:||Performs a trace line from the start to the end, returns 0 if something was hit and 1 otherwise. The pass_entities sets the number of entity bounding boxes that are assumed to be 'invisible'. mins and maxs set the bounding box within the sighttrace. It is performed to save CPU usage. (See also setsize command).||
||Comment:||The same command is found in the Entity class.||
to:
||Example:||@@sighttrace ( 20 30 3045 ) ( 0 0 0 ) 1 ( -16 -16 -16) (16 16 16)@@||
||Description:||Performs a trace line from the start to the end, returns 0 if something was hit and 1 otherwise. The pass_entities sets the number of entity bounding boxes that are assumed to be 'invisible'. Passes through masked objects (fences, treelines etc.). mins and maxs set the bounding box of the sighttrace. This allows you to check if an object of a certain size could reach a destination, as opposed to the simple line trace performed when mins and maxs are omitted. Also see setsize command. Sighttrace returns 1 if end can be reached, 0 otherwise. The 'trace' command is similar but will return the position it hit at.||
||Comment:||The same command is found in the Entity class. This command differs from the one in the ScriptThread class only in that it will ignore the Entity that issues it itself (can't hit self).||
March 12, 2005, at 01:13 PM by bjarne
Changed lines 321-322 from:
||Description:||Specify the location to move the actor to, with the animation anim used. '''I think you need to use 'waitmove' after this for the move to occur -- dcoshea''' Nope, not for actors ;) -- [[jv_map]]||
to:
||Description:||Specify the location to move the actor to, with the animation anim used.||

Comments to the AI '''moveto''' command:
* I think you need to use 'waitmove' after this for the move to occur -- [[Profiles/dcoshea|dcoshea]]
* Nope, not for actors ;) -- [[Profiles/jv_map|jv_map]]
Changed lines 331-336 from:
[[Elevator|Elevator tutorial]]

[[SpawnNewThingsIntoStockMapsWithScripting|Spawn stuff in maps from the script]]

[[Liberation in MOH:AA|Liberation game mode in MOH:AA]]
to:
* [[Elevator|Elevator tutorial]]
* [[SpawnNewThingsIntoStockMapsWithScripting|Spawn stuff in maps from the script]]
* [[Liberation in MOH:AA|Liberation game mode in MOH:AA]]
January 31, 2005, at 04:00 PM by bjarne
Changed lines 5-6 from:
When you know how to script, its time to start using the commands that you can invoke from the scripting language. This document is a list of commands paired with descriptions and other explanations of how best to use them. It is by no means all of the commands, just the most common and / or the ones that needs to be explained the most. For a complete ( but short ) definition of ALL commands, see the file [[http://www.planetmedalofhonor.com/rjukanproject/other_files/g_allclasses.html|g_allclasses.html]] ( for Allied Assault ) and [[http://www.planetmedalofhonor.com/rjukanproject/other_files/MOH_GameClasses.html|MOH_GameClasses.html]] ( for Spearhead ).
to:
When you know how to script, its time to start using the commands that you can invoke from the scripting language. This document is a list of commands paired with descriptions and other explanations of how best to use them. It is by no means all of the commands, just the most common and / or the ones that needs to be explained the most. For a complete ( but short ) definition of ALL commands, see the file Attach:g_allclasses.html ( for Allied Assault ) and Attach:MOH_GameClasses.html ( for Spearhead ).
Changed lines 36-37 from:
An optional command is written within 'square' parentheses - [[]].
to:
An optional command is written within 'square' parentheses - [].
Changed line 291 from:
||Syntax:||Player iprint ( String stuffToPrint, [[ Integer bold ]] )||
to:
||Syntax:||Player iprint ( String stuffToPrint, [ Integer bold ] )||
January 31, 2005, at 02:56 AM by bjarne
Added lines 1-332:
!MOHAA script language, Appendix A ( Commands )

!!Commands

When you know how to script, its time to start using the commands that you can invoke from the scripting language. This document is a list of commands paired with descriptions and other explanations of how best to use them. It is by no means all of the commands, just the most common and / or the ones that needs to be explained the most. For a complete ( but short ) definition of ALL commands, see the file [[http://www.planetmedalofhonor.com/rjukanproject/other_files/g_allclasses.html|g_allclasses.html]] ( for Allied Assault ) and [[http://www.planetmedalofhonor.com/rjukanproject/other_files/MOH_GameClasses.html|MOH_GameClasses.html]] ( for Spearhead ).

It would be a good idea to cross-read [[MOHAA Script language appendix B]] ( about classes ) as a refrerence when reading this document.

!!Table of contents

(:toc:)

!!Definitions and syntax

The format used to describe the commands is like this:

||border=1
||Command:||Name of the command.||
||Syntax:||What class this command is sent to, and any parameters it supports is described here.||
||Example:||A code snippet exemplifying how to use the command.||
||Description:||A textual description of the command. When best to use it. When not to use it. Dark secrets and government conspiracy linked to the command.||
||Comment:||Any details not fitting into the above will be fitted into this space ( if any ).||

The 'Syntax' section is declared like this:

class_name name_of_command ( parameter_1_type, parameter_1_descriptive name, [optional_parameter_2_type, optional_parameter_2_descriptive name] ).

'''Example''': cansee( Entity entity, [Float fov], [Float vision_distance] ).

'''Example explanation''': The class 'Entity' supports a command named 'cansee'. This command requires a parameter of the class 'Entity', and you may also supply the two 'Float' parameters fov & vision_distance. Any place where a certain class is required, any class inheriting from that class will also work just as well.

In short:

A commands parameter list is written within parentheses - ( ).

An optional command is written within 'square' parentheses - [[]].

!!General

||border=1
||Command:||thread||
||Syntax:||thread ( String label )||
||Example:||@@exec background_player_scanner@@||
||Description:||This command executes from the specified label in a new thread.||

||border=1
||Command:||waitthread||
||Syntax:||waitthread ( String label )||
||Example:||@@waitthread initialize_spawns@@||
||Description:||This command executes from the specified label in a new thread and waits until the called thread group is finished. That means the next line in the script wont be executed until the other thread is done.||

||border=1
||Command:||exec||
||Syntax:||exec ( String script )||
||Example:||@@exec my_personal_script_file.scr@@||
||Description:||This command executes the specified script.||

||border=1
||Command:||waitexec||
||Syntax:||waitexec ( String script )||
||Example:||@@waitexec my_personal_script_file.scr@@||
||Description:||This command executes the specified script and waits until the called thread group is finished. That means the next line in the script wont be executed until the other executed script is done.||

||border=1
||Command:||waitTill||
||Syntax:||waitTill ( String eventName )||
||Example:||@@$vip_player waitTill death@@||
||Description:||Wait until event of type eventName.||

||border=1
||Command:||commanddelay||
||Syntax:||commanddelay ( Float delay, String command, [ String [arg1] ], [ String [arg2] ], [ String [arg3] ], [ String [arg4] ], [ String [arg5] ], [ String [arg6] ] )||
||Example:||@@commanddelay 3.0 $door close@@||
||Description:||Executes a command after the given time delay. The example above is equivalent to: @@wait 3.0@@ followed by @@$door close@@ except that with 'commanddelay' the thread executing the code can perform other actions in those 3 seconds, whereas with 'wait' the thread is suspended.||

!!Object manipulation

!!!Existence

||border=1
||Command:||hide||
||Syntax:||hide||
||Example:||@@$document_to_steal hide@@||
||Description:||This command hides an object so that it is invisible to the player. It's status is not sent from the server to the client, so a player will not experience it. The object still exists. If it is already hidden, nothing happens.||

||border=1
||Command:||show||
||Syntax:||show||
||Example:||@@$document_to_steal show@@||
||Description:||This command shows an object so that it is visible to the player. If it was already shown... nothing really happens.||

||border=1
||Command:||remove||
||Syntax:||remove||
||Example:||@@$document_to_steal remove@@||
||Description:||This command removes an object so that it no longer exists in the game.||

||border=1
||Command:||removeclass||
||Syntax:||removeclass ( String class_name, [Integer except] )||
||Example:||@@removeclass script_object@@||
||Description:||Removes everything in the specified class except for the specified entity (optional) so that it no longer exists in the game. ||

!!!Rotation

||border=1
||Command:||rotateX, rotateY, rotateZ||
||Syntax:||rotateX ( Float angular_velocity )||
||Example:||@@$fan rotateX 1.5@@||
||Description:||Rotate about the X ( or Y or Z ) axis at the specified angular velocity. The angular_velocity represents the speed to rotate the object.||

||border=1
||Command:||rotateXdown, rotateYdown, rotateZdown||
||Syntax:||rotateXdown ( Float angle )||
||Example:||@@$trapdoor rotateXdown 45.0@@||
||Description:||Rotate the X ( or Y or Z ) down by the specified angle. The angle represents the angle to rotate the object.||

||border=1
||Command:||rotateXup, rotateYup, rotateZup||
||Syntax:||rotateXup ( Float angle )||
||Example:||@@$trapdoor rotateXup 45.0@@||
||Description:||Rotate the X ( or Y or Z ) up by the specified angle. The angle parameter represents the angle to rotate the object.||

||border=1
||Command:||rotateXdownto, rotateYdownto, rotateZdownto||
||Syntax:||rotateXdownto ( Float angle )||
||Example:||@@$trapdoor rotateXdownto 45.0@@||
||Description:||rotate the X ( or Y or Z ) down to angle. The angle parameter represents the angle to rotate the object.||

||border=1
||Command:||rotateXupto, rotateYupto, rotateZupto||
||Syntax:||rotateXdownto ( Float angle )||
||Example:||@@$trapdoor rotateXdownto 45.0@@||
||Description:||Rotate the X ( or Y or Z ) up to angle. The angle parameter represents the angle to rotate the object.||

!!!Movement

||border=1
||Command:||move, waitmove||
||Syntax:||move||
||Example:||@@$elevator moveto $waypoint_down@@||
||Example:||@@$elevator move@@||
||Description: ||Move the script slave. This command executes the previous movement commands sent to a ScriptSlave ( the class of a script_object ). The waitmove command also waits for the move to complete before continuing execution.||

||border=1
||Command:||'''moveto'''||
||Syntax:||moveto ( Entity destination )||
||Example:||@@$elevator moveto $top_floor@@||
||Description:||Move to the specified entity.||

||border=1
||Command:||moveup, movedown, moveForward, moveBackward, moveLeft, moveRight, moveEast, moveNorth, moveSouth, moveWest||
||Syntax:||moveup ( Float distance )||
||Example:||@@$elevator moveup 64@@||
||Description: ||Move the specified distance ( Measured in world units ).||

!!Object status tests

||border=1
||Command:||isAlive||
||Syntax:||isAlive||
||Example:||@@if !(isAlive $vip_player){teamwin axis}@@||
||Description:||This command checks to see if something is alive. If it is, 1 is returned else 0 is returned ( if it is "dead" that is ). The definition of life ( in MOH ) is to have more than 0 in health.||

||border=1
||Command:||isTouching||
||Syntax:||isTouching ( Entity entity )||
||Example:||@@if !($player[local.index] isTouching $it){teamwin axis}@@||
||Description:||This command checks to see if two objects are touching. If they are, 1 is returned else 0 is returned. ( Not sure about his commands usage and function, tell me more! ).||

Remarks by [[jv_map]]: since this command simply checks whether the bounding boxes of the two objects intersect, this doesn't work well for concave shapes. Also this command may return true even if both objects are non-solid. I think for Breakthrough you can use isInside instead.

||border=1
||Command:||sighttrace||
||Syntax:||sighttrace ( Vector start, Vector end, [ Integer pass_entities ], [ Vector mins ], [ Vector maxs ] )||
||Example:||@@sighttrace ( 20 30 3045 ) ( 0 0 0 ) 1@@||
||Description:||Performs a trace line from the start to the end, returns 0 if something was hit and 1 otherwise. The pass_entities sets the number of entity bounding boxes that are assumed to be 'invisible'. mins and maxs set the bounding box within the sighttrace. It is performed to save CPU usage. (See also setsize command).||
||Comment:||The same command is found in the Entity class.||

!!Damage

Some commands have a parameter named '''meansofdeath''' ( ''damage'' and ''killed'' in the Player class as an example). It is an integer that use these values:

||border=1
||'''Id'''||'''Name'''||'''Description'''||
||0||MOD_NONE||
||1||MOD_SUICIDE||
||2||MOD_CRUSH||
||3||MOD_CRUSH_EVERY_FRAME||
||4||MOD_TELEFRAG||
||5||MOD_LAVA||
||6||MOD_SLIME||
||7||MOD_FALLING||
||8||MOD_LAST_SELF_INFLICTED||
||9||MOD_EXPLOSION||
||10||MOD_EXPLODEWALL||
||11||MOD_ELECTRIC||
||12||MOD_ELECTRICWATER||
||13||MOD_THROWNOBJECT||
||14||MOD_BEAM||
||15||MOD_ROCKET||
||16||MOD_IMPACT||
||17||MOD_BULLET||
||18||MOD_FAST_BULLET||
||19||MOD_VEHICLE||
||20||MOD_FIRE||
||21||MOD_FLASHBANG||
||22||MOD_ON_FIRE||
||23||MOD_GIB||
||24||MOD_IMPALE||
||25||MOD_BASH||
||26||MOD_TOTAL_NUMBER||

Remarks by [[jv_map]]: Not sure if you can actually enter the number corresponding to the meansofdeath value, but you can enter the string belonging to it (that is without the 'MOD_' part, like 'bullet').

!!Sound

Sound is played on a distinct channel, here is a list of the available channels:

||border=1
||'''Id'''||'''Name'''||'''Description'''||
||0||auto||This is considered the lowest audio channel priority. It always plays if possible (hardware audio channel available) and they don't override previously played sounds. If no channels are available, the sound will just not play. This is best used for things that do not have a particular entity or character related to them (like bullet hit sounds), or are not overly important sound (like shell casing landing sounds or footsteps).||
||1||body||These are sounds made by a characters body. These include sounds like impact sounds (from falling & landing hard) and equipment movement jingles.||
||2||item||These are sounds made by items on a character, or that represent some sort of item related sound. These would include sounds made by any misc items carried by a character like papers or binorulars, but could also be used as a second weapon sound channel if it is required for a weapon to play two different sounds at the same time. This is also the channel that should be used for weapon reload sound to prevent them from cutting off long firing sounds.||
||3||weaponidle||Is for constant sound made by weapons or possibly the character itself. An example from Quake3 would be the rail gun hum, but I can't think of any examples from MoH, exept a low mumbling of the player commenting on how mush he/she loves his/her gun..||
||4||voice||These are vocal sounds made by a character such as pain, death, and yelling during combat. This is effectively a lower priority dialog channel for general use throughout the majority of the game.||
||5||local||This plays a sound that is considered to be "local" to the player. Meaning, it does not do 3D spatialization on the sound. It does adjust the volume of the sound according to distance though. This is best used for playing sounds that should sound omni-directional like rain or lightning.||
||6||weapon||These are the sound that are made by the characters' weapons. These include the firing sounds, but not reloading sounds.||
||7||dialog_secondary||This is a secondary backup dialog channel. Good for use with lower priority dialog such as idle chatter between characters, as it's considered to be lower priority than regular dialog. This should only include spoken dialog that will have subtitle text.||
||8||dialog||This is the primary sound channel for playing character dialog. This should only include spoken dialog that will have subtitle text.||
||9||menu||This is the sound channel for menu sounds to play on.||

||border=1
||Command:||playsound||
||Syntax:||playsound ( String soundName, [ Integer channel ], [ Float volume ], [ Float min_distance ], [ Float pitch ] )||
||Example:||@@$radio playsound "emergency_broadcast" 7@@||
||Description:||Plays a sound coming from this entity. Default channel is body ( 1 ).||

||border=1
||Command:||stopsound||
||Syntax:||stopsound ( [ Integer channel ] )||
||Example:||@@$radio stopsound 7@@||
||Description:||Stops the current sound on the specified channel. Default channel is body ( 1 ).||

||border=1
||Command:||loopsound||
||Syntax||loopsound ( String soundName, [ Float volume ], [ String minimum_distance ] )||
||Example:||@@$radio loopsound "ether_static"@@||
||Description:||Play a looped-sound with a certain volume and minimum_distance which is attached to the current entity.||

||border=1
||Command:||stoploopsound||
||Syntax:||stoploopsound||
||Example:||@@$radio stoploopsound@@||
||Description:||Stop the looped-sound on this entity.||

!!Text printing

||border=1
||Command:||print, println||
||Syntax:||print ( String text )||
||Example:||@@print "It came from the script ( desert? )!"@@||
||Description:||Prints a message in the consol. The println version is followed by a line break.||

||border=1
||Command:||iprintln, iprintlnbold||
||Syntax:||iprintln ( String text )||
||Example:||@@iprintln "It came from the script ( desert? )!"@@||
||Description:||Prints a message on the left side of the screen in yellow ( no clicking sound ) followed by a line break. The bold version uses the same font, but in white and clicking.||

||border=1
||Command:||iprintln_noloc, iprintlnbold_noloc||
||Syntax:||iprintln_noloc ( String text )||
||Example:||@@iprintln_noloc "Elvis has left the building!"@@||
||Description:||Prints a message on the left side of the screen in white ( with a clicking sound ) followed by a line break. Bold version uses a bold font.||

||border=1
||Command:||locprint||
||Syntax:||locprint ( Integer X_offset, Integer Y_offset, String text )||
||Example:||@@locprint 30, 100, "Here I am!"@@||
||Description:||Prints a message in the specified X-Y location of all player's screens.||

||border=1
||Command:||centerprint||
||Syntax:||centerprint ( String stuffToPrint )||
||Example:||@@centerprint "5 health penalty awarded!"@@||
||Description:||Prints the text desired into the center of the screen, On all resolutions.||

||border=1
||Command:||Player iprint||
||Syntax:||Player iprint ( String stuffToPrint, [[ Integer bold ]] )||
||Example:||@@$player "This is printed to all players"@@ @@$player[local.i] "This is printed to the player with index local.i, in bold" 1@@||
||Description:||Prints the text desired on the left side of the screen in yellow (no clicking sound) followed by a line break, or, if bold is set to 1, as in the second example, in white (with a clicking sound).||

!!Mathematic

||border=1
||Command:||abs||
||Syntax:||abs ( Float argument )||
||Example:||@@abs -23.656@@||
||Description:||Returns the absolute value of the parameter. abs 15.3 returns 15.3. abs -2 returns 2. abs -5.999 returns 5.999. So it basically converts any number to a positive one by removing the minus sign.||

||border=1
||Command:||randomfloat||
||Syntax:||randomfloat ( Float max )||
||Example:||@@randomfloat 14.9@@||
||Description:||Returns a random number between 0 and 'max', inclusive of 0 and exclusive of 'max' (i.e. 'max' will never be returned).||

||border=1
||Command:||randomint||
||Syntax:||randomint ( Integer max )||
||Example:||@@randomint 10@@||
||Description:||Returns a random number between 0 and 'max', inclusive of 0 and exclusive of 'max' (i.e. 'max' will never be returned).||

!!!AI

||border=1
||Command:||'''moveto'''||
||Syntax:||moveto ( String anim, String dest )||
||Example: ||@@$evil_one moveto "anim/my_animation" "there"@@||
||Description:||Specify the location to move the actor to, with the animation anim used. '''I think you need to use 'waitmove' after this for the move to occur -- dcoshea''' Nope, not for actors ;) -- [[jv_map]]||

!!!Command combinations

Here are some tutorials with appiled scripting.

[[Elevator|Elevator tutorial]]

[[SpawnNewThingsIntoStockMapsWithScripting|Spawn stuff in maps from the script]]

[[Liberation in MOH:AA|Liberation game mode in MOH:AA]]

Recent Changes Printable View Page History Edit Page [Attributes] [Printable View] [WikiHelp]
Page last modified on July 09, 2005, at 11:45 AM